package edu.erpan.entities.administracion;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import edu.erpan.util.entityManager.DefaultEntity;


/**
 * The persistent class for the usuarios database table.
 * 
 */
@Entity
@Table(name="usuarios")
public class Usuario extends DefaultEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(unique=true, nullable=false)
	private int idusuario;

	@Column(length=15)
	private String login;

	@Column(length=45)
	private String password;

	//uni-directional many-to-many association to Rol
	@ManyToMany(fetch=FetchType.EAGER)
	@JoinTable(
		name="rolesxusuario"
		, joinColumns={
			@JoinColumn(name="usuarios_idusuario", nullable=false)
			}
		, inverseJoinColumns={
			@JoinColumn(name="roles_idrol", nullable=false)
			}
		)
	private Set<Rol> roles;

	//bi-directional many-to-one association to Persona
    @ManyToOne
	@JoinColumn(name="persona_idpersona", nullable=false)
	private Persona persona;

    public Usuario() {
    }

	public int getIdusuario() {
		return this.idusuario;
	}

	public void setIdusuario(int idusuario) {
		this.idusuario = idusuario;
	}

	public String getLogin() {
		return this.login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Set<Rol> getRoles() {
		return this.roles;
	}

	public void setRoles(Set<Rol> roles) {
		this.roles = roles;
	}
	
	public Persona getPersona() {
		return this.persona;
	}

	public void setPersona(Persona persona) {
		this.persona = persona;
	}
	
}